package com.example.demo.tests;

import com.example.demo.commen.Utils;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;

public class EditPage extends Utils {

    public static String url = "http://127.0.0.1:8080/blog_edit.html";

    public EditPage() {
        super(url);
    }

    public void EditSuc() throws InterruptedException {
        String blogTitle = "java111";

        //第一种方法
         driver.findElement(By.cssSelector("#title")).sendKeys("java111");

         //发布
         driver.findElement(By.cssSelector("#submit")).click();


         //检查
       String title = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.title")).getText();

       assert title.equals(blogTitle);

      //  WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(2));

       /* //第二种方法
        WebElement ele = driver.findElement(By.cssSelector("#editor > div.CodeMirror.cm-s-default.CodeMirror-wrap > div.CodeMirror-scroll > div.CodeMirror-sizer > div > div > div > div.CodeMirror-code > div > pre"));
        Actions actions = new Actions(driver);

        Thread.sleep(3000);
        //perform作用:为了在页面看到效果
        actions.doubleClick(ele).perform();
        Thread.sleep(3000);
        actions.keyDown(Keys.DELETE).perform();
        Thread.sleep(3000);
        actions.moveToElement(ele).sendKeys("键盘鼠标输入博客内容").perform();
        Thread.sleep(3000);*/




        driver.quit();
    }






}
